const express = require('express');
const router = express.Router();

// 导入各模块路由
const authRouter = require('./auth');
const homeRouter = require('./home');
const studyRouter = require('./study');
const detectionRouter = require('./detection');
const gameRouter = require('./game');
const dailyRouter = require('./daily');
const notificationRouter = require('./notifications');
const statisticsRouter = require('./statistics');
const uploadRouter = require('./upload');

// 注册路由
router.use('/auth', authRouter);
router.use('/home', homeRouter);
router.use('/study', studyRouter);
router.use('/detection', detectionRouter);
router.use('/game', gameRouter);
router.use('/daily', dailyRouter);
router.use('/notifications', notificationRouter);
router.use('/statistics', statisticsRouter);
router.use('/upload', uploadRouter);

// 健康检查接口
router.get('/health', (req, res) => {
  res.json({
    code: 200,
    message: 'success',
    data: {
      status: 'healthy',
      timestamp: Date.now(),
      version: '1.0.0'
    }
  });
});

// 404 处理
router.use('*', (req, res) => {
  res.status(404).json({
    code: 404,
    message: '接口不存在',
    data: null,
    timestamp: Date.now()
  });
});

module.exports = router;
